package cn.dapeng.ticket;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Ticket_Demo05 {

    static final List<String> tickets = Collections.synchronizedList(new ArrayList<>());

    static {
        for (int i = 0; i < Constant.TICKET_NUM; i++) {
            tickets.add("ticket-num:" + i);
        }
    }

    public static void main(String[] args) {

        for (int i = 0; i < Constant.THREAD_NUM; i++) {
            new Thread(() -> {
                while (!tickets.isEmpty()) {
                    System.out.println(tickets.remove(0));
                }
            }).start();

        }
    }

}
